const express = require("express");

const app = express();

// 注册中间件 下面这两行代码能让 req.body 有值，而不是 undefined
app.use(express.json());
app.use(express.urlencoded());

// http://localhost:3000/hello
app.get("/hello", (req, res, next) => {
  // req.query 能获取到 url地址上 ？号传递过来的参数
  console.log(req.query); // { name: 张三, age: 18 }
  res.send("11111");
});

app.post("/hello", (req, res, next) => {
  console.log(req.body);
  res.send("11111");
});

app.listen(3000);
